package fatworm.query;

import fatworm.metadata.StatInfo;
import fatworm.tx.Transaction;
import fatworm.server.*;
import fatworm.storage.table.*;

public class TablePlan implements Plan {
	
	private TableInfo ti;
	private Transaction tx;
	private StatInfo si;
	
	public TablePlan(String name, Transaction tx) {
		this.tx = tx;
		
		ti = Fatworm.mdMgr().getTableInfo(name, tx);
		si = Fatworm.mdMgr().getStatInfo(name, ti, tx);
	}
	
	public Scan open() {
		return new TableScan(ti, tx);
	}
	
	public int blocksAccessed() {
		return si.blocksAccessed();
	}
	
	public int recordsOutput() {
		return si.recordsOutput();
	}
	
	public int distinctValues(String name) {
		return si.distinctValues(name);
	}
	
	public Schema getSchema() {
		return ti.schema();
	}
	
}